@extends('seller::layout.master')

@section('title', __('seller::withdraw.title'))

@section('content')
@if ($errors->has('error'))
<x-seller-alert type="danger" msg="{!! $errors->first('error') !!}" class="mt-4" />
@endif

@if (session()->has('success'))
<x-seller-alert type="success" msg="{{ session('success') }}" class="mt-4" />
@endif

<div class="card">
  <div class="card-body h-min-600">
    <div class="d-flex justify-content-between mb-4">
      <a href="{{ seller_route('withdraws.create') }}" class="btn btn-primary">{{ __('common.add') }}</a>
    </div>
    <div class="table-push">
      @if (count($withdraws))
      <table class="table">
        <thead>
          <tr>
            <th>ID</th>
            <th>{{ __('common.status') }}</th>
            <th>{{ __('seller::withdraw.withdraw_amount') }}</th>
            <th>{{ __('seller::withdraw.paid_status') }}</th>
            <th>{{ __('common.created_at') }}</th>
            <th>{{ __('common.updated_at') }}</th>
          </tr>
        </thead>
        <tbody>
          @foreach ($withdraws as $item)
          <tr>
            <td>{{ $item['id'] }}</td>
            <td class="{{ $item['status'] ? 'text-success' : 'text-secondary' }}">
              {{ $item['status'] ? __('seller::withdraw.text_processed') : __('seller::withdraw.text_Pending') }}
            </td>
            <td>{{ $item['amount'] }}</td>
            <td>{{ $item['paid_at'] ? __('seller::withdraw.paid') . " ({$item['paid_at']}) " : ($item['status'] ? __('seller::withdraw.refused') : '') }}</td>
            <td>{{ $item['created_at'] }}</td>
            <td>{{ $item['updated_at'] }}</td>
          </tr>
          @endforeach
        </tbody>
      </table>
      @else
      <div>
        <x-seller-no-data />
      </div>
      @endif
    </div>
  </div>
</div>
@endsection
